//
// Created by Administrator on 2024/10/30.
//

#ifndef AI_PACS_DCMTOOLKIT_H
#define AI_PACS_DCMTOOLKIT_H

#include <iostream>
#include <utility>
#include "dcmtk/dcmdata/dctk.h"
#include "Coroutine.h"
#include "UuidGenerate.h"
#include "dcmtk/dcmdata/dcdict.h"
#include "log.h"
#include <format>

#define REQUIRED_TAGS { \
        DCM_TransferSyntaxUID,\
        DCM_PatientName,\
        DCM_PatientID,\
        DCM_PatientBirthDate,\
        DCM_PatientBirthDate,\
        DCM_PatientSex,\
        DCM_PatientAge,\
        DCM_PatientWeight,\
        DCM_StudyInstanceUID,\
        DCM_StudyID,\
        DCM_AccessionNumber,\
        DCM_StudyDate,\
        DCM_StudyTime,\
        DCM_Modality,\
        DCM_SeriesInstanceUID,\
        DCM_SeriesNumber,\
        DCM_SeriesDate,\
        DCM_SeriesTime,\
        DCM_SeriesDescription,\
        DCM_BodyPartExamined,\
        DCM_SliceThickness,\
        DCM_SpacingBetweenSlices,\
        DCM_SliceLocation,\
        DCM_PerformedProcedureStepDescription,\
        DCM_ProtocolName,\
        DCM_SOPInstanceUID,\
        DCM_InstanceCreationDate,\
        DCM_InstanceCreationTime,\
        DCM_NumberOfFrames,\
        DCM_Manufacturer,\
        DCM_StationName,\
        DCM_ManufacturerModelName,\
        DCM_DeviceSerialNumber,\
        DCM_PatientBirthTime,\
        DCM_InstitutionName,\
        DCM_OperatorsName,\
        DCM_AcquisitionTime,\
        DCM_RadionuclideTotalDose,\
        DCM_RadiopharmaceuticalStartTime,\
        DCM_RadionuclideHalfLife,\
        DCM_DoseCalibrationFactor,\
        DCM_InstanceNumber,\
        DCM_PixelSpacing,\
        DCM_SamplesPerPixel,\
        DCM_PixelPaddingValue,\
        DCM_Columns,\
        DCM_Rows,\
        DCM_WindowWidth,\
        DCM_WindowCenter,\
        DCM_RescaleType,\
        DCM_RescaleSlope,\
        DCM_RescaleIntercept,\
        DCM_RETIRED_ImagePosition,\
        DCM_ImagePositionPatient,\
        DCM_RETIRED_ImageOrientation,\
        DCM_ImageOrientationPatient,\
        DCM_BitsAllocated,\
        DCM_BitsStored,\
        DCM_HighBit,\
        DCM_PixelRepresentation,\
        DCM_DiffusionBValue,\
        DCM_PhotometricInterpretation,\
        DCM_ImageType,\
        DCM_StudyDescription,\
}

class DcmToolKit {
public:
    static void printTags(const std::string &filename);

    static std::map<std::string, std::string> findTags(const std::string &filename, const std::vector<DcmTagKey> &tags,std::string &hospCode);

    static std::string getObjKeyByPretzelProtocol(std::map<std::string, std::string> dict);

    static Promise<std::map<std::string, std::string>> Gather(std::vector<std::string> files,std::string &hospCode);

    static std::vector<std::map<std::string, std::string>> Executor(std::vector<std::string> &files,std::string &hospCode);

    static std::string getObjKeyByPrefix(std::map<std::string, std::string> dict);
};

#endif //AI_PACS_DCMTOOLKIT_H
